package com.situ.company.score.service.impl;

import java.util.List;

import com.situ.company.score.dao.IScoreDao;
import com.situ.company.score.dao.impl.ScoreDaoImpl;
import com.situ.company.score.model.ScoreModel;
import com.situ.company.score.service.IScoreService;

public class ScoreServiceImpl implements IScoreService{
	
	private IScoreDao dao = new ScoreDaoImpl();

	@Override
	public String insert(ScoreModel model) {
		ScoreModel mdb=selectModel(model);
		if(mdb!=null) {
			return "repeat";
		}
		return dao.insert(model)+"";
	}

	@Override
	public String delete(ScoreModel model) {
		Integer res=dao.delete(model);
		return res==null?null:res.toString();
	}

	@Override
	public String update(ScoreModel model) {
		return dao.updateAll(model)+"";
	}

	@Override
	public List<ScoreModel> selectList(ScoreModel model) {
		String codeEmp=model.getCodeEmp();
		model.setCodeEmp(codeEmp==null?"%":"%"+codeEmp+"%");
		String codePro=model.getCodePro();
		model.setCodePro(codePro==null?"%":"%"+codePro+"%");
		return dao.selectList(model);
	}

	@Override
	public ScoreModel selectModel(ScoreModel model) {
		return dao.selectModel(model);
	}

	@Override
	public Integer selectCount(ScoreModel model) {
		ScoreModel m1=new ScoreModel();
		String codeEmp=model.getCodeEmp();
		m1.setCodeEmp(codeEmp==null?"%":"%"+codeEmp+"%");
		String codePro=model.getCodePro();
		m1.setCodePro(codePro==null?"%":"%"+codePro+"%");
		return dao.selectCount(m1);
	}

}
